import config from '@/config'
import { getNewsTypeListTitle, getNewsList, getNewsDetail } from '@/api/news/news'

const baseUrl = config.baseUrl

const news = {
    mutations: {

    },

    actions: {
        //获取新闻类别
        GetNewsTypeListTitle({ commit }) {
            return new Promise((resolve, reject) => {
                getNewsTypeListTitle({}).then(res => {
                    resolve(res)
                }).catch(error => {
                    reject(error)
                })
            })
        },
        //获取新闻列表
        GetNewsList({ commit }, typeId) {
            return new Promise((resolve, reject) => {
                getNewsList({ typeId }).then(res => {
                    resolve(res)
                }).catch(error => {
                    reject(error)
                })
            })
        },
        //获取新闻详情
        GetNewsDetail({ commit }, id) {
            return new Promise((resolve, reject) => {
                getNewsDetail({ id }).then(res => {
                    resolve(res)
                }).catch(error => {
                    reject(error)
                })
            })
        }
    }
}

export default news
